Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1057 - Expanded plotting options of plot_posterior_predictive #1058

Closed
wants to merge 11 commits into from

Conversation

jsnyde0
Copy link
Contributor

@jsnyde0 jsnyde0 commented Sep 20, 2024

Description

The `plot_posterior_predictive' function has gotten new plotting options. Depending on the parameters, it can also show:

  • HDI (Highest Density Intervals) at 94% and 50% levels (as before)
  • Mean prediction line (new)
  • Gradient representation of the full posterior distribution (new)

The new function argument related to this are:

  • add_hdi : bool, optional - If True, add highest density intervals to the plot. Default is True.
  • add_mean : bool, optional - If True, add the mean prediction to the plot. Default is True.
  • add_gradient : bool, optional - If True, add a gradient representation of the full posterior distribution. Default is False.

A new example notebook is added to demonstrate: mmm_plotting_options.ipynb

Related Issue

Checklist

Modules affected

  • MMM
  • CLV

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc-marketing--1058.org.readthedocs.build/en/1058/

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@juanitorduz
Copy link
Collaborator

juanitorduz commented Sep 23, 2024

Thanks @jsnyde0 . Can you please add additional tests in

@pytest.mark.parametrize(
argnames="func_plot_name, kwargs_plot",
argvalues=[
("plot_prior_predictive", {}),
("plot_posterior_predictive", {}),
("plot_posterior_predictive", {"original_scale": True}),
("plot_posterior_predictive", {"ax": plt.subplots()[1]}),
("plot_errors", {}),
("plot_errors", {"original_scale": True}),
("plot_errors", {"ax": plt.subplots()[1]}),
("plot_waterfall_components_decomposition", {"original_scale": True}),
("plot_channel_contribution_share_hdi", {"hdi_prob": 0.95}),
("plot_grouped_contribution_breakdown_over_time", {}),
(
"plot_grouped_contribution_breakdown_over_time",
{
"stack_groups": {"controls": ["control_1"]},
"original_scale": True,
"area_kwargs": {"alpha": 0.5},
},
),
("plot_components_contributions", {}),
],
)
def test_plots(self, plotting_mmm, func_plot_name, kwargs_plot) -> None:
func = plotting_mmm.__getattribute__(func_plot_name)
assert isinstance(func(**kwargs_plot), plt.Figure)
plt.close("all")

:)

juanitorduz and others added 5 commits September 24, 2024 10:36
…pymc-labs#1060)

* feat: test.txt added for commit check

* feat: replaced plot_curve with plot_samples within ./mmm/plot.py

* fix: plot_samples instead of plot_sample
* feat: test.txt added for commit check

* feat: replaced plot_curve with plot_samples within ./mmm/plot.py

* feat: n_samples added to distributions_new_customers

* revert the plot.py changes

---------

Co-authored-by: Juan Orduz <[email protected]>
@jsnyde0
Copy link
Contributor Author

jsnyde0 commented Sep 24, 2024

@juanitorduz done!

Also, I messed up the commit history so I made a new branch & PR: #1066

@wd60622
Copy link
Contributor

wd60622 commented Sep 24, 2024

@juanitorduz done!

Also, I messed up the commit history so I made a new branch & PR: #1066

Feel free to close the pr that is now stale

@jsnyde0 jsnyde0 closed this Sep 25, 2024
@jsnyde0 jsnyde0 deleted the expand-plot-posterior branch September 30, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request MMM plots
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expanding plotting options of plot_posterior_predictive
5 participants